﻿namespace FFXIRC_CLIENT
{
    using System;
    using System.Net;
    using System.Net.Sockets;
    using System.IO;
    using System.Threading;
    /*
    * This program works as a simple IRC Client
    */
    class IrcClient
    {
        // User information defined in RFC 2812 (Internet Relay Chat: Client Protocol) is sent to irc server
        // StreamWriter is declared here so that PingSender can access it
        public static Meebey.SmartIrc4net.IrcUser myUser;
        public static Meebey.SmartIrc4net.IrcClient myClient;
        public static FFXI_to_IRC f2i;
        public static IRC_to_FFXI i2f;


        public static void setupClient()
        {
            myClient = new Meebey.SmartIrc4net.IrcClient();
            f2i = new FFXI_to_IRC();
            i2f = new IRC_to_FFXI();
            try
            {
                myUser = new Meebey.SmartIrc4net.IrcUser(FFXI.FFACE.Player.Name(), myClient);
                f2i.Start();
                i2f.Start();
            }
            catch (Exception e)
            {
                // Show the exception, sleep for a while and try to establish a new connection to irc server
                Console.WriteLine(e.ToString());
                Thread.Sleep(5000);
                setupClient();
            }
        }
    }
}